#include <REGX52.H>
#include "Delay.h"



unsigned char juzhenKey()
{
	unsigned char keynumber = 0;
	
	P3=0xff;
	P3_7=0;
	if(P3_0==0){Delay(20); while(!P3_0); Delay(20); keynumber=1;}
	if(P3_1==0){Delay(20); while(!P3_1); Delay(20); keynumber=5;}
	if(P3_2==0){Delay(20); while(!P3_2); Delay(20); keynumber=9;}
	if(P3_3==0){Delay(20); while(!P3_3); Delay(20); keynumber=13;}
	
	P3=0xff;
	P3_6=0;
	if(P3_0==0){Delay(20); while(!P3_0); Delay(20); keynumber=2;}
	if(P3_1==0){Delay(20); while(!P3_1); Delay(20); keynumber=6;}
	if(P3_2==0){Delay(20); while(!P3_2); Delay(20); keynumber=10;}
	if(P3_3==0){Delay(20); while(!P3_3); Delay(20); keynumber=14;}
	
	P3=0xff;
	P3_5=0;
	if(P3_0==0){Delay(20); while(!P3_0); Delay(20); keynumber=3;}
	if(P3_1==0){Delay(20); while(!P3_1); Delay(20); keynumber=7;}
	if(P3_2==0){Delay(20); while(!P3_2); Delay(20); keynumber=11;}
	if(P3_3==0){Delay(20); while(!P3_3); Delay(20); keynumber=15;}
	
	P3=0xff;
	P3_4=0;
	if(P3_0==0){Delay(20); while(!P3_0); Delay(20); keynumber=4;}
	if(P3_1==0){Delay(20); while(!P3_1); Delay(20); keynumber=8;}
	if(P3_2==0){Delay(20); while(!P3_2); Delay(20); keynumber=12;}
	if(P3_3==0){Delay(20); while(!P3_3); Delay(20); keynumber=16;}

	return keynumber;
}